﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Telerik.Web.UI;
using SMA.GENTEv1;

public partial class Protegidos_Pessoas_DadosPessoa_pAdvertSusp : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    #region Eventos
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        CarregarAdvertencias();
        RadGrid1.DataBind();
    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        CarregarAdvertencias();
    }
    protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
    {
        int id = int.Parse((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["IdAdvertencia"].ToString());

        PessoaAdvertencia advertencia = new PessoaAdvertencia();
        advertencia.IdAdvertencia = id;

        advertencia.Excluir();

        CarregarAdvertencias();
    }
    #endregion

    #region Metodos
    private void CarregarAdvertencias()
    {
        PessoaAdvertencia advertencia = new PessoaAdvertencia();
        RadGrid1.DataSource = advertencia.SelectPorPessoa(IdPessoa);
    }
    #endregion
}
